package com.libs.mymodbuslibdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.libs.modbus.MbManager;
import com.libs.modbus.interfaces.OnInitListener;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MbManager.getInstance().init(this, new OnInitListener() {
            @Override
            public void success() {
                Log.d("xxxxx,","success ");
            }

            @Override
            public void error(int i) {
                Log.d("xxxxx,","error : "+i);
            }
        });
    }

    public void readRG(View view){
        new Thread(new Runnable() {
            @Override
            public void run() {
                int code = MbManager.getInstance().read_registers(110);
                Log.d("xxxxx,","code : "+code);
        }
        }).start();

    }
}
